<!--
  @author:  long
  @date:    2024/5/30
  @file:    xx
  @require:
-->
<template>
  <div class="advancedSetting app-container">
    <el-divider border-style="dashed">
      <el-tag type="danger">
        <el-icon color="red">
          <WarnTriangleFilled />
        </el-icon>
        危险区
      </el-tag>
    </el-divider>
    <div class="text-xl mb-10px">删除项目</div>
    <div class="text-lg text-gray-400 mb-10px">
      如果此项目已经不再需要了，你可以删除它。删除后如果想找回该项目，可以通过配置中心由管理员进行恢复。
    </div>
    <el-button type="danger" @click="delProject" class="w110px"
      >删除项目
    </el-button>
  </div>
</template>

<script setup name="AdvancedSetting">
import { getCurrentInstance } from 'vue'
import { ElMessageBox } from 'element-plus'
import { delRepaymentProject } from '@/api/researchManage/projectManage'
import useTagsViewStore from '@/store/modules/tagsView'

const router = useRouter()
const { proxy } = getCurrentInstance()
const projectId = ref('')
watch(
  () => proxy.$route.query,
  newQuery => {
    // 处理参数变化
    console.log('newQuery', newQuery)
    projectId.value = newQuery.projectId
  },
  { immediate: true }
)
//删除项目
const delProject = () => {
  ElMessageBox.confirm(
    '<p class="mb-5px">确认删除该项目吗?</p><p class="text-base text-gray-400">删除后如果想找回该项目，可以通过配置中心由管理员进行恢复。</p>',
    '确认删除',
    {
      dangerouslyUseHTMLString: true,
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }
  )
    .then(() => {
      delRepaymentProject(projectId.value).then(res => {
        useTagsViewStore().delView(router.currentRoute.value)

        proxy.$router.push('/researchManage/projectManage')
      })
    })
    .catch(() => {})
}
</script>

<style scoped lang="scss"></style>
